const { merge } = require("webpack-merge");

const MiniCssExtractPlugin = require("mini-css-extract-plugin");

const baseConfig = require("./webpack.config");

module.exports = merge(baseConfig, {
  mode: "production",
  module: {
    rules: [
      {
        test: /\.(scss|sass)$/i,
        use: [
          MiniCssExtractPlugin.loader, // 使用插件提供的 loader 提取 CSS
          "css-loader",
          "sass-loader",
        ],
      },
    ],
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: "styles/[name].[contenthash].css", // 输出到 styles 目录，带内容哈希
    }),
  ],
  optimization: {
    minimize: true,
    splitChunks: {
      chunks: "all",
    },
  },
});
